package cn.com.dhcc.turbo.service.stat;
 
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import cn.com.dhcc.app.core.CM;
import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.app.core.util.UUIDGenerator;
import cn.com.dhcc.app.pub.core.consts.AppConst;
import cn.com.dhcc.turbo.entity.stat.StBtNodeNumm;
import cn.com.dhcc.turbo.entity.stat.StBtNodeNumy;
import cn.com.dhcc.turbo.entity.stat.Stbtdttopm;
import cn.com.dhcc.turbo.entity.stat.Stbtdttopy;
import cn.com.dhcc.turbo.entity.stat.Stbtnettopm;
import cn.com.dhcc.turbo.entity.stat.Stbtnettopy;
import cn.com.dhcc.turbo.entity.stat.Stbtregy;
import cn.com.dhcc.turbo.entity.stat.StloRelAdapterRatem;
import cn.com.dhcc.turbo.entity.stat.StloRelAdapterRatey;
import cn.com.dhcc.turbo.entity.stat.StloRelNodeRatem;
import cn.com.dhcc.turbo.entity.stat.StloRelNodeRatey;
import cn.com.dhcc.turbo.entity.stat.Stlonumadapterm;
import cn.com.dhcc.turbo.entity.stat.Stlonumadaptery;
import cn.com.dhcc.turbo.entity.stat.Stlonumdtypem;
import cn.com.dhcc.turbo.entity.stat.Stlonumdtypey;
import cn.com.dhcc.turbo.entity.stat.Stlonumm;
import cn.com.dhcc.turbo.entity.stat.Stlonumnetm;
import cn.com.dhcc.turbo.entity.stat.Stlonumnety;
import cn.com.dhcc.turbo.entity.stat.Stlonumy;


/**
 * 统计入库
 * 
 * @日期 2014-12-11 下午5:54:06
 * @作者  高强
 */
@Service
public class StatManageService extends BaseService {

	private String DAY_PATTERN="yyyy-MM-dd";
	private String MONTH_PATTER="yyyy-MM";
	private String YEAR_PATTER="yyyy";
	/**
	 *  本节点接收和发送次数(月)
	 * 入库表 turbo_st_lo_num_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者  高强
	 */
	public void statStlonummByDay(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一天的记录
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(DAY_PATTERN);
		String staDateStr=sdf.format(staDate);
		String pattern=DAY_PATTERN;
		//从最小粒度系统开始统计，包括turbo_send_cm_data和turbo_send_file_data表
		String sql=" select own_id,sum(num) num,to_date(nt,'"+pattern+"') nt" +
				"  from " +
				" (" +
				"     select id as own_id," +
				"            case when num is null then 0 else num end num," +
				"            case when nt is null then '"+staDateStr+"' else nt end nt " +
				"     from " +
				"     (" +
				"        select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+" a" +
				"        inner join "+SI_TABLE("turbo_node_info")+"  n on n.node_code=a.node_code" +
				"        left join " +
				"        (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_send_cm_data")+" where to_char(created,'"+pattern+"')=? and MSG_TYPE!=? "+
                "         group by to_char(created,'"+pattern+"'),send_adaptorcode " +
                "        ) cm on a.adapter_code=cm.send_adaptorcode" +
                "        where n.islocal='1' " +
                "       union all " +
                "      select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+"  a" +
                "      inner join "+SI_TABLE("TURBO_NODE_INFO")+"   n on n.node_code=a.node_code" +
                "      left join " +
                "       (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_send_file_data")+" where to_char(created,'"+pattern+"')=? "+
                "         group by to_char(created,'"+pattern+"'),send_adaptorcode" +
                "       ) f on a.adapter_code=f.send_adaptorcode" +
                "        where n.islocal='1' " +
				"     )" +
				"  ) " +
				"group by nt,own_id";
		try {
			/**********************按照适配器统计发送 入库start **********************************/
			List<Stlonumm> adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumm.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
			for (Stlonumm stlonumm : adapterList) {
				stlonumm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumm.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
				stlonumm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_m")+" t where t.exch_type=? and stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),AppConst.StatLevel.ADAPTER.value(),staDateStr});
		    if (adapterList!=null && !adapterList.isEmpty()) {
		    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			}
			/**********************按照适配器统计发送 入库end **********************************/
			
			/**********************按照适配器统计 接收入库start **********************************/
			 sql=" select own_id,sum(num) num,to_date(nt,'"+pattern+"') nt " +
						"  from " +
						" (" +
						"     select id as own_id," +
						"            case when num is null then 0 else num end num," +
						"            case when nt is null then '"+staDateStr+"' else nt end nt " +
						"     from " +
						"     (" +
						"        select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+" a" +
						"        inner join "+SI_TABLE("turbo_node_info")+"  n on n.node_code=a.node_code" +
						"         left join " +
						"        (select count(*) num,to_char(created,'"+pattern+"') as nt,recv_adaptorcode from "+SI_TABLE("turbo_recv_cm_data")+" where to_char(created,'"+pattern+"')=? "+
		                "         group by to_char(created,'"+pattern+"'),recv_adaptorcode " +
		                "        ) cm on a.adapter_code=cm.recv_adaptorcode " +
		                "        where n.islocal='1' " +
		                "       union all " +
		                "      select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+"  a" +
		            	"        inner join "+SI_TABLE("turbo_node_info")+"   n on n.node_code=a.node_code" +
		                "      left join " +
		                "       (select count(*) num,to_char(created,'"+pattern+"') as nt,recv_adaptorcode from "+SI_TABLE("turbo_recv_file_data")+" where to_char(created,'"+pattern+"')=? "+
		                "         group by to_char(created,'"+pattern+"'),recv_adaptorcode" +
		                "       ) f on a.adapter_code=f.recv_adaptorcode" +
		                "        where n.islocal='1' " +
						"     )" +
						"  ) " +
						"group by nt,own_id";
			adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumm.class, new Object[]{staDateStr,staDateStr});
			for (Stlonumm stlonumm : adapterList) {
				stlonumm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumm.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
				stlonumm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_m")+" t where t.exch_type=? and stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),AppConst.StatLevel.ADAPTER.value(),staDateStr});
			 if (adapterList!=null && !adapterList.isEmpty()) {
			   CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			 }
			/**********************按照适配器统计接收发送 入库end **********************************/
			
			/**********************按照业务域统计发送和接收入库start **********************************/
			sql=" select exch_type,t1.id own_id,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt,sum(num) num "+
                "  from "+SI_TABLE("turbo_domain_info")+" t1 "+
                "  left join "+SI_TABLE("turbo_data_category")+" t2 on t1.id = t2.domain_id "+
                " inner join "+
                " ( "+
                "   select t4.data_code, t5.nt, t5.num, t5.exch_type "+
                "   from "+SI_TABLE("turbo_adapter_info")+" t3 "+
                " left join  "+SI_TABLE("turbo_adapter_base")+" t4 on t3.adapter_code = t4.adapter_code"+
                "   inner join "+SI_TABLE("turbo_st_lo_num_m")+" t5 on t5.own_id = t3.id " +
                "   where  t5.stat_level=? and to_char(nt,'"+pattern+"')=?"+
                " ) t23 on t23.data_code = t2.data_code "+
                " group by exch_type, to_char(nt,'"+pattern+"') ,t1.id";
			List<Stlonumm> domianList=CM.getDao().listModule("按照业务域统计["+staDateStr+"]的量", sql, Stlonumm.class, new Object[]{AppConst.StatLevel.ADAPTER.value(), staDateStr});
			for (Stlonumm stlonumm : domianList) {
				stlonumm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumm.setStatLevel(AppConst.StatLevel.DOMAIN.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.DOMAIN.value(),staDateStr});
			if (domianList!=null && !domianList.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", domianList);
			}
			/**********************按照业务域统计发送和接收入库end **********************************/
			
	       /**********************按照节点统计接收入库start **********************************/
			sql="select t2.id own_id,t3.exch_type,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt,sum(num) num"+
                " from "+SI_TABLE("turbo_adapter_info")+" t1 "+
                " inner join "+SI_TABLE("turbo_node_info")+" t2 on t1.node_code=t2.node_code "+
                " inner join "+SI_TABLE("turbo_st_lo_num_m")+" t3 on t3.own_id=t1.id "+
                " where t2.islocal='1' and t3.stat_level=? and to_char(nt,'"+pattern+"')=?"+
                " group by t3.exch_type,to_char(t3.nt,'"+pattern+"'),t2.id";
			List<Stlonumm> nodeList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, Stlonumm.class, new Object[]{AppConst.StatLevel.ADAPTER.value(), staDateStr});
			for (Stlonumm stlonumm : nodeList) {
				stlonumm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumm.setStatLevel(AppConst.StatLevel.NODE.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.NODE.value(),staDateStr});
			if (nodeList!=null && !nodeList.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照节点统计["+staDateStr+"]的量", nodeList);
			}
			/**********************按照节点域统计接收入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**私有方法
	 * * @作者  高强
	 * @param staDateStr
	 * @param pattern
	 * @param now
	 * @param level
	 * @throws DaoException
	 */
	private void statStlonummByMonth(String staDateStr,String pattern,Date now,AppConst.StatLevel level) throws DaoException{
		String sql=" select exch_type,own_id,sum(num) num,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt "+
				" from "+SI_TABLE("turbo_st_lo_num_m")+
				" where to_char(nt,'"+pattern+"')=? and  stat_level=?"+
				" group by exch_type,to_char(nt,'"+pattern+"'),own_id";
			List<Stlonumy> list=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumy.class, new Object[]{staDateStr,level.value()});
			for (Stlonumy stlonumy : list) {
				stlonumy.setId(UUIDGenerator.getUUID());//设置主键
				stlonumy.setStatLevel(level.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumy.setmTime(now);//统计时间
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_y")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除按照"+level.getDesc()+"["+staDateStr+"]的发送数据统计", sql, new Object[]{level.value(),staDateStr});
			if (list!=null && !list.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照"+level.getDesc()+"统计["+staDateStr+"]的量", list);
			}
	}
	
	/**
	 *  本节点接收和发送次数(年)
	 *  按月分组
	 * 入库表 turbo_st_lo_num_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者  高强
	 */
	public void statStlonumyByMonth(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一个月
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
//		String sql="";
		try {
		/**********************按照适配器统计发送 入库start **********************************/
		statStlonummByMonth(staDateStr, pattern, now, AppConst.StatLevel.ADAPTER);
		/**********************按照适配器统计发送 入库end **********************************/
		
		/**********************按照业务域统计发送 入库start **********************************/
		statStlonummByMonth(staDateStr, pattern, now, AppConst.StatLevel.DOMAIN);
		/**********************按照业务域统计发送 入库end **********************************/
		
		
		/**********************按照节点统计发送 入库start **********************************/
		statStlonummByMonth(staDateStr, pattern, now, AppConst.StatLevel.NODE);
		/**********************按照节点统计发送 入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**
	 *  同本节点交换频率最高的节点（月）
	 *  一个月存入一条记录
	 *  按月分组
	 * 入库表 turbo_st_lo_rel_node_rate_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者：樊晓晓
	 */
	public void statStloRelNodeRatemByMonth(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		String sql=null;
		try {
		 /**********************发送 类型 start   *****************************************/
		  sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.id exch_node_id, " +
				    " case when t1.num is null then 0 else t1.num end num " +
		  		" from "+
			    "(" +
				" select nt,send_nodecode,recv_nodecode,sum(num) num from "+
			    "   ("+
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) num from "+SI_TABLE("turbo_recv_cm_data")+
			    " 	where to_char(created,'"+pattern+"')=?  "+
			    " 	group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode "+
			    " 	union all " +
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) num from "+SI_TABLE("turbo_recv_file_data")+
			    "   where to_char(created,'"+pattern+"')=? " +
			    "   group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode" +
			    "   ) group by nt,send_nodecode,recv_nodecode"+
			    ") t1 " + 
			    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
		        " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
		  List<StloRelNodeRatem> sendList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, StloRelNodeRatem.class, new Object[]{staDateStr,staDateStr});
			for (StloRelNodeRatem stloRelNodeRatem : sendList) {
				stloRelNodeRatem.setId(UUIDGenerator.getUUID());//设置主键
				stloRelNodeRatem.setExchType(AppConst.StaExchType.RECV.value());//
				stloRelNodeRatem.setmTime(now);//统计时间
			}
		   //删除staDateStr当月的量
		   sql="delete from "+SI_TABLE("turbo_st_lo_rel_node_rate_m")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
		   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),staDateStr});
		  if (sendList!=null && !sendList.isEmpty()) {
			  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
		}
		   /**********************发送 类型 end *****************************************/
		   
		   /***********************接收类型 start***************************************************/
		   sql=" select to_date(nt,'"+pattern+"') nt,t2.id node_id,t3.id exch_node_id," +
				       " case when t1.num is null then 0 else t1.num end num " +
			  		" from "+
				    "(" +
			  		" select nt,recv_nodecode,send_nodecode,sum(num) num from "+
				    "   ("+
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) num from "+SI_TABLE("turbo_send_cm_data")+
				    " 	where to_char(created,'"+pattern+"')=? and msg_type!=? "+
				    " 	group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode "+
				    " 	union all " +
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) num from "+SI_TABLE("turbo_send_file_data")+
				    "   where to_char(created,'"+pattern+"')=? " +
				    "   group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode" +
				    "   ) group by nt,recv_nodecode,send_nodecode"+
				    ") t1 " +
				    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
			        " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
			  List<StloRelNodeRatem> recvList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, StloRelNodeRatem.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
				for (StloRelNodeRatem stloRelNodeRatem : recvList) {
					stloRelNodeRatem.setId(UUIDGenerator.getUUID());//设置主键
					stloRelNodeRatem.setExchType(AppConst.StaExchType.SEND.value());//
					stloRelNodeRatem.setmTime(now);//统计时间
				}
			   //删除staDateStr当月的量
			   sql="delete from "+SI_TABLE("turbo_st_lo_rel_node_rate_m")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
			   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),staDateStr});
			   if (recvList!=null && !recvList.isEmpty()) {
			     CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", recvList);
			   }
		   /***********************接收类型 end***************************************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
		
	}
	
	/**
	 *  同本节点交换频率最高的节点（年）
	 *  一年存入一条记录
	 *  按年分组
	 * 入库表 turbo_st_lo_rel_node_rate_y
	 * @param staDate  统计日期
	 * @throws ServiceException
	 * @作者：樊晓晓 
	 */
	public void statStloRelNodeRateyByYear(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=YEAR_PATTER;
		String sql=null;
		try {
		 /**********************发送 类型 start   *****************************************/
		  sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.id exch_node_id, " +
				  " case when t1.num is null then 0 else t1.num end num " +
		  		" from "+
			    "(" +
				" select nt,send_nodecode,recv_nodecode,sum(num) num from "+
			    "   ("+
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) num from "+SI_TABLE("turbo_recv_cm_data")+
			    " 	where to_char(created,'"+pattern+"')=?  "+
			    " 	group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode "+
			    " 	union all " +
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) num from "+SI_TABLE("turbo_recv_file_data")+
			    "   where to_char(created,'"+pattern+"')=? " +
			    "   group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode" +
			    "   ) group by nt,send_nodecode,recv_nodecode"+
			    ") t1 " +
			    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
		        " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
		  List<StloRelNodeRatey> sendList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, StloRelNodeRatey.class, new Object[]{staDateStr,staDateStr});
			for (StloRelNodeRatey stloRelNodeRatey : sendList) {
				stloRelNodeRatey.setId(UUIDGenerator.getUUID());//设置主键
				stloRelNodeRatey.setExchType(AppConst.StaExchType.RECV.value());//
				stloRelNodeRatey.setmTime(now);//统计时间
			}
		   //删除staDateStr当月的量
		   sql="delete from "+SI_TABLE("turbo_st_lo_rel_node_rate_y")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
		   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),staDateStr});
		   if (sendList!=null && !sendList.isEmpty()) {
		   CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
		   }
		   /**********************发送 类型 end *****************************************/
		   
		   /***********************接收类型 start***************************************************/
		   sql=" select to_date(nt,'"+pattern+"') nt,t2.id node_id,t3.id exch_node_id, " +
				       " case when t1.num is null then 0 else t1.num end num " +
			  		" from "+
				    "(" +
					" select nt,recv_nodecode,send_nodecode,sum(num) num from "+
				    "   ("+
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) num from "+SI_TABLE("turbo_send_cm_data")+
				    " 	where to_char(created,'"+pattern+"')=? and msg_type!=? "+
				    " 	group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode "+
				    " 	union all " +
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) num from "+SI_TABLE("turbo_send_file_data")+
				    "   where to_char(created,'"+pattern+"')=? " +
				    "   group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode" +
				    "   ) group by nt,recv_nodecode,send_nodecode"+
				    ") t1 "+
				    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
			        " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
			  List<StloRelNodeRatey> recvList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, StloRelNodeRatey.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
				for (StloRelNodeRatey stloRelNodeRatey : recvList) {
					stloRelNodeRatey.setId(UUIDGenerator.getUUID());//设置主键
					stloRelNodeRatey.setExchType(AppConst.StaExchType.SEND.value());//
					stloRelNodeRatey.setmTime(now);//统计时间
				}
			   //删除staDateStr当月的量
			   sql="delete from "+SI_TABLE("turbo_st_lo_rel_node_rate_y")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
			   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),staDateStr});
			   if (recvList!=null && !recvList.isEmpty()) {
			   CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", recvList);
			   }
		   /***********************接收类型 end***************************************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
		
	}
	
	
	
	/**
	 *  同本节点交换频率最高的系统（月）
	 *  一个月存入一条记录
	 *  按月分组
	 * 入库表 turbo_st_lo_rel_adapter_rate_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者  高强
	 */
	public void statStloRelAdapterRatemByMonth(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		String sql=null;
		try {
		 /**********************发送 类型 start   *****************************************/
		  sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.ADAPTER_CODE ADAPTER_CODE,t1.num " +
		  		" from "+
			    "(" +
				" select nt,send_nodecode,send_adaptorcode,sum(num) num from "+
			    "   ("+
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,send_adaptorcode,count(*) num from "+SI_TABLE("turbo_send_cm_data")+
			    " 	where to_char(created,'"+pattern+"')=?  "+
			    " 	group by to_char(created,'"+pattern+"'),send_nodecode,send_adaptorcode "+
			    " 	union all " +
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,send_adaptorcode,count(*) num from "+SI_TABLE("turbo_send_file_data")+
			    "   where to_char(created,'"+pattern+"')=? " +
			    "   group by to_char(created,'"+pattern+"'),send_nodecode,send_adaptorcode" +
			    "   ) group by nt,send_nodecode,send_adaptorcode"+
			    ") t1 " +	  
			    " inner join "+SI_TABLE("TURBO_ADAPTER_BASE")+" t2 on t1.send_adaptorcode=t2.ADAPTER_CODE " +
			    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.send_nodecode=t3.node_code";
		  List<StloRelAdapterRatem> sendList=CM.getDao().listModule("按照业务系统统计["+staDateStr+"]的量", sql, StloRelAdapterRatem.class, new Object[]{staDateStr,staDateStr});
			for (StloRelAdapterRatem StloRelAdapterRatem : sendList) {
				StloRelAdapterRatem.setId(UUIDGenerator.getUUID());//设置主键
				StloRelAdapterRatem.setExchType(AppConst.StaExchType.SEND.value());//
				StloRelAdapterRatem.setmTime(now);//统计时间
			}
		   //删除staDateStr当月的量
		   sql="delete from "+SI_TABLE("turbo_st_lo_rel_adapter_rate_m")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
		   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),staDateStr});
		  if (sendList!=null && !sendList.isEmpty()) {
			  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
		}
		   /**********************发送 类型 end *****************************************/
		   
		   /***********************接收类型 start***************************************************/
		   sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.ADAPTER_CODE ADAPTER_CODE,t1.num " +
			  		" from "+
				    "(" +
			  		" select nt,recv_nodecode,recv_adaptorcode,sum(num) num from "+
				    "   ("+
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,recv_adaptorcode,count(*) num from "+SI_TABLE("turbo_recv_cm_data")+
				    " 	where to_char(created,'"+pattern+"')=? and msg_type!=? "+
				    " 	group by to_char(created,'"+pattern+"'),recv_nodecode,recv_adaptorcode "+
				    " 	union all " +
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,recv_adaptorcode,count(*) num from "+SI_TABLE("turbo_recv_file_data")+
				    "   where to_char(created,'"+pattern+"')=? " +
				    "   group by to_char(created,'"+pattern+"'),recv_nodecode,recv_adaptorcode" +
				    "   ) group by nt,recv_nodecode,recv_adaptorcode"+
				    ") t1 " +	  
				    " inner join "+SI_TABLE("TURBO_ADAPTER_BASE")+" t2 on t1.recv_adaptorcode=t2.ADAPTER_CODE " +
				    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
			  List<StloRelAdapterRatem> recvList=CM.getDao().listModule("按照业务系统统计["+staDateStr+"]的量", sql, StloRelAdapterRatem.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
				for (StloRelAdapterRatem StloRelAdapterRatem : recvList) {
					StloRelAdapterRatem.setId(UUIDGenerator.getUUID());//设置主键
					StloRelAdapterRatem.setExchType(AppConst.StaExchType.RECV.value());//
					StloRelAdapterRatem.setmTime(now);//统计时间
				}
			   //删除staDateStr当月的量
			   sql="delete from "+SI_TABLE("turbo_st_lo_rel_adapter_rate_m")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
			   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),staDateStr});
			   if (recvList!=null && !recvList.isEmpty()) {
			     CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", recvList);
			   }
		   /***********************接收类型 end***************************************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
		
	}
	
	/**
	 *  同本节点交换频率最高的系统（年）
	 *  一年存入一条记录
	 *  按年分组
	 * 入库表 turbo_st_lo_rel_adapter_rate_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者  高强
	 */
	public void statStloRelAdapterRateyByYear(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=YEAR_PATTER;
		String sql=null;
		try {
		 /**********************发送 类型 start   *****************************************/
		  sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.ADAPTER_CODE ADAPTER_CODE,t1.num "+
		  		" from "+
			    "(" +
				" select nt,send_nodecode,send_adaptorcode,sum(num) num from "+
			    "   ("+
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,send_adaptorcode,count(*) num from "+SI_TABLE("turbo_send_cm_data")+
			    " 	where to_char(created,'"+pattern+"')=?  "+
			    " 	group by to_char(created,'"+pattern+"'),send_nodecode,send_adaptorcode "+
			    " 	union all " +
			    "   select to_char(created,'"+pattern+"') nt,send_nodecode,send_adaptorcode,count(*) num from "+SI_TABLE("turbo_send_file_data")+
			    "   where to_char(created,'"+pattern+"')=? " +
			    "   group by to_char(created,'"+pattern+"'),send_nodecode,send_adaptorcode" +
			    "   ) group by nt,send_nodecode,send_adaptorcode"+
			    ") t1 " +	  
			    " inner join "+SI_TABLE("TURBO_ADAPTER_BASE")+" t2 on t1.send_adaptorcode=t2.adapter_code " +
			    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.send_nodecode=t3.node_code";
		  List<StloRelAdapterRatey> sendList=CM.getDao().listModule("按照业务系统统计["+staDateStr+"]的量", sql, StloRelAdapterRatey.class, new Object[]{staDateStr,staDateStr});
			for (StloRelAdapterRatey StloRelAdapterRatey : sendList) {
				StloRelAdapterRatey.setId(UUIDGenerator.getUUID());//设置主键
				StloRelAdapterRatey.setExchType(AppConst.StaExchType.SEND.value());//
				StloRelAdapterRatey.setmTime(now);//统计时间
			}
		   //删除staDateStr当月的量
		   sql="delete from "+SI_TABLE("turbo_st_lo_rel_adapter_rate_y")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
		   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),staDateStr});
		  if (sendList!=null && !sendList.isEmpty()) {
			  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
		}
		   /**********************发送 类型 end *****************************************/
		   
		   /***********************接收类型 start***************************************************/
		   sql=" select to_date(nt,'"+pattern+"') nt,t3.id node_id,t2.ADAPTER_CODE ADAPTER_CODE,t1.num "+
			  		" from "+
				    "(" +
					" select nt,recv_nodecode,recv_adaptorcode,sum(num) num from "+
				    "   ("+
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,recv_adaptorcode,count(*) num from "+SI_TABLE("turbo_recv_cm_data")+
				    " 	where to_char(created,'"+pattern+"')=? and msg_type!=? "+
				    " 	group by to_char(created,'"+pattern+"'),recv_nodecode,recv_adaptorcode "+
				    " 	union all " +
				    "   select to_char(created,'"+pattern+"') nt,recv_nodecode,recv_adaptorcode,count(*) num from "+SI_TABLE("turbo_recv_file_data")+
				    "   where to_char(created,'"+pattern+"')=? " +
				    "   group by to_char(created,'"+pattern+"'),recv_nodecode,recv_adaptorcode" +
				    "   ) group by nt,recv_nodecode,recv_adaptorcode"+
				    ") t1 " +	  
				    " inner join "+SI_TABLE("TURBO_ADAPTER_BASE")+" t2 on t1.recv_adaptorcode=t2.adapter_code " +
				    " inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code";
			  List<StloRelAdapterRatey> recvList=CM.getDao().listModule("按照业务系统统计["+staDateStr+"]的量", sql, StloRelAdapterRatey.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
				for (StloRelAdapterRatey StloRelAdapterRatey : recvList) {
					StloRelAdapterRatey.setId(UUIDGenerator.getUUID());//设置主键
					StloRelAdapterRatey.setExchType(AppConst.StaExchType.RECV.value());//
					StloRelAdapterRatey.setmTime(now);//统计时间
				}
			   //删除staDateStr当月的量
			   sql="delete from "+SI_TABLE("turbo_st_lo_rel_adapter_rate_y")+" t where exch_type=? and to_char(nt,'"+pattern+"')=?";
			   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),staDateStr});
			   if (recvList!=null && !recvList.isEmpty()) {
			      CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", recvList);
			   }
		   /***********************接收类型 end***************************************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
		
	}
	
	/**
	 * 本节点内外网交换频次(月)
	 * 按天分组，每天统计一次
	 * 入库表 turbo_st_lo_num_net_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:何鹏
	 */
	public void statStlonumnetmByDay(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一天的记录
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(DAY_PATTERN);
		String staDateStr=sdf.format(staDate);
		String pattern=DAY_PATTERN;
		//从最小粒度系统开始统计，包括turbo_send_cm_data和turbo_send_file_data表
		String sql=" select own_id,sum(num) num,to_date(nt,'"+pattern+"') nt" +
				"  from " +
				" (" +
				"     select id as own_id," +
				"            case when num is null then 0 else num end num," +
				"            case when nt is null then '"+staDateStr+"' else nt end nt " +
				"     from " +
				"     (" +
				"        select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+" a" +
				"        inner join "+SI_TABLE("turbo_node_info")+"  n on n.node_code=a.node_code" +
				"        left join " +
				"        (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_send_cm_data")+" where to_char(created,'"+pattern+"')=? and MSG_TYPE!=? and CROSS_NET!='0' "+
                "         group by to_char(created,'"+pattern+"'),send_adaptorcode " +
                "        ) cm on a.adapter_code=cm.send_adaptorcode" +
                "        where n.islocal='1' " +
                "       union all " +
                "      select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+"  a" +
                "      inner join "+SI_TABLE("turbo_node_info")+"   n on n.node_code=a.node_code" +
                "      left join " +
                "       (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_send_file_data")+" where to_char(created,'"+pattern+"')=? and CROSS_NET!='0' "+
                "         group by to_char(created,'"+pattern+"'),send_adaptorcode" +
                "       ) f on a.adapter_code=f.send_adaptorcode" +
                "        where n.islocal='1' " +
				"     )" +
				"  ) " +
				"group by nt,own_id";
		try {
			/**********************按照适配器统计发送 入库start **********************************/
			List<Stlonumnetm> adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumnetm.class, new Object[]{staDateStr,AppConst.MsgType.GROUP_MSG.value(),staDateStr});
			for (Stlonumnetm stlonumnetm : adapterList) {
				stlonumnetm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumnetm.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
				stlonumnetm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumnetm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_net_m")+" t where t.exch_type=? and stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.SEND.value(),AppConst.StatLevel.ADAPTER.value(),staDateStr});
		    if (adapterList!=null && !adapterList.isEmpty()) {
		    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			}
			/**********************按照适配器统计发送 入库end **********************************/
			
			/**********************按照适配器统计 接收入库start **********************************/
			 sql=" select own_id,sum(num) num,to_date(nt,'"+pattern+"') nt " +
						"  from " +
						" (" +
						"     select id as own_id," +
						"            case when num is null then 0 else num end num," +
						"            case when nt is null then '"+staDateStr+"' else nt end nt " +
						"     from " +
						"     (" +
						"        select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+" a" +
						"        inner join "+SI_TABLE("turbo_node_info")+"  n on n.node_code=a.node_code" +
						"         left join " +
						"        (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_recv_cm_data")+" where to_char(created,'"+pattern+"')=? and CROSS_NET!='0' "+
		                "         group by to_char(created,'"+pattern+"'),send_adaptorcode " +
		                "        ) cm on a.adapter_code=cm.send_adaptorcode " +
		                "        where n.islocal='1' " +
		                "       union all " +
		                "      select adapter_code, a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+"  a" +
		            	"        inner join "+SI_TABLE("turbo_node_info")+"   n on n.node_code=a.node_code" +
		                "      left join " +
		                "       (select count(*) num,to_char(created,'"+pattern+"') as nt,send_adaptorcode from "+SI_TABLE("turbo_recv_file_data")+" where to_char(created,'"+pattern+"')=? and CROSS_NET!='0' "+
		                "         group by to_char(created,'"+pattern+"'),send_adaptorcode" +
		                "       ) f on a.adapter_code=f.send_adaptorcode" +
		                "        where n.islocal='1' " +
						"     )" +
						"  ) " +
						"group by nt,own_id";
			adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumnetm.class, new Object[]{staDateStr,staDateStr});
			for (Stlonumnetm stlonumnetm : adapterList) {
				stlonumnetm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumnetm.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
				stlonumnetm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumnetm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_net_m")+" t where t.exch_type=? and stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StaExchType.RECV.value(),AppConst.StatLevel.ADAPTER.value(),staDateStr});
			 if (adapterList!=null && !adapterList.isEmpty()) {
			   CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			 }
			/**********************按照适配器统计接收发送 入库end **********************************/
			
			/**********************按照业务域统计发送和接收入库start **********************************/
			sql=" select exch_type,t1.id own_id,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt,sum(num) num "+
                " from "+SI_TABLE("turbo_domain_info")+" t1 "+
                " left join "+SI_TABLE("turbo_data_category")+" t2  on t1.id = t2.domain_id"+
                " left join "+
                " ( "+
                "   select t4.data_code, t5.nt, t5.num, t5.exch_type "+
                "   from "+SI_TABLE("turbo_adapter_info")+" t3 "+
                "   left join "+SI_TABLE("turbo_adapter_base")+" t4 on t3.adapter_code = t4.adapter_code"+
                "   inner join "+SI_TABLE("turbo_st_lo_num_net_m")+" t5 on t5.own_id = t3.id " +
                "   where  t5.stat_level=? and to_char(nt,'"+pattern+"')=?"+
                " ) t23 on t23.data_code = t2.data_code "+
                " group by exch_type, to_char(nt,'"+pattern+"') ,t1.id";
			List<Stlonumnetm> domianList=CM.getDao().listModule("按照业务域统计["+staDateStr+"]的量", sql, Stlonumnetm.class, new Object[]{AppConst.StatLevel.ADAPTER.value(), staDateStr});
			for (Stlonumnetm stlonumnetm : domianList) {
				stlonumnetm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumnetm.setStatLevel(AppConst.StatLevel.DOMAIN.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumnetm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_net_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.DOMAIN.value(),staDateStr});
			if (domianList!=null && !domianList.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", domianList);
			}
			/**********************按照业务域统计发送和接收入库end **********************************/
			
	       /**********************按照节点统计接收入库start **********************************/
			sql="select t2.id own_id,t3.exch_type,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt,sum(num) num"+
                " from "+SI_TABLE("turbo_node_info")+" t1 "+
                " inner join "+SI_TABLE("turbo_adapter_info")+" t2 on t1.node_code=t2.node_code "+
                " inner join "+SI_TABLE("turbo_st_lo_num_net_m")+" t3 on t3.own_id=t1.id "+
                " where t2.islocal='1' and t3.stat_level=? and to_char(nt,'"+pattern+"')=?"+
                " group by t3.exch_type,to_char(t3.nt,'"+pattern+"'),t2.id";
			List<Stlonumnetm> nodeList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, Stlonumnetm.class, new Object[]{AppConst.StatLevel.ADAPTER.value(), staDateStr});
			for (Stlonumnetm stlonumnetm : nodeList) {
				stlonumnetm.setId(UUIDGenerator.getUUID());//设置主键
				stlonumnetm.setStatLevel(AppConst.StatLevel.NODE.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumnetm.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_net_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.NODE.value(),staDateStr});
			if (nodeList!=null && !nodeList.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照节点统计["+staDateStr+"]的量", nodeList);
			}
			/**********************按照节点域统计接收入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	
	private void statStlonumnetmByMonth(String staDateStr,String pattern,Date now,AppConst.StatLevel level) throws DaoException{
		String sql=" select exch_type,own_id,sum(num) num,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt "+
				" from "+SI_TABLE("turbo_st_lo_num_net_m")+
				" where to_char(nt,'"+pattern+"')=? and  stat_level=?"+
				" group by exch_type,to_char(nt,'"+pattern+"'),own_id";
			List<Stlonumnety> list=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumnety.class, new Object[]{staDateStr,level.value()});
			for (Stlonumnety stlonumnety : list) {
				stlonumnety.setId(UUIDGenerator.getUUID());//设置主键
				stlonumnety.setStatLevel(level.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumnety.setmTime(now);//统计时间
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_net_y")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除按照"+level.getDesc()+"["+staDateStr+"]的发送数据统计", sql, new Object[]{level.value(),staDateStr});
			if (list!=null && !list.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照"+level.getDesc()+"统计["+staDateStr+"]的量", list);
			}
	}
	
	/**
	 * 本节点内外网交换频次(年)
	 * 按月分组，每月统计一次
	 * 入库表 turbo_st_lo_num_net_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:何鹏
	 */
	public void statStlonumnetmByMonth(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一个月
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		try {
		/**********************按照适配器统计发送 入库start **********************************/
		statStlonumnetmByMonth(staDateStr, pattern, now, AppConst.StatLevel.ADAPTER);
		/**********************按照适配器统计发送 入库end **********************************/
		
		/**********************按照业务域统计发送 入库start **********************************/
		statStlonumnetmByMonth(staDateStr, pattern, now, AppConst.StatLevel.DOMAIN);
		/**********************按照业务域统计发送 入库end **********************************/
		
		
		/**********************按照节点统计发送 入库start **********************************/
		statStlonumnetmByMonth(staDateStr, pattern, now, AppConst.StatLevel.NODE);
		/**********************按照节点统计发送 入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**
	 *  本节点接收发送频次(按适配器)(月)
	 * 入库表 turbo_st_lo_num_adapter_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStlonumsysmByMonth(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一天的记录
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		//从最小粒度系统开始统计，包括turbo_send_cm_data和turbo_send_file_data表
		try {
			/**********************按照适配器统计发送 入库start **********************************/
			String sql=" select adapter_code ,id as own_id ,sum(num)as num ,nt from ( select a.adapter_code,a.id,num,nt " +
			          " from "+SI_TABLE("turbo_adapter_info")+" a  , (select count (*) num, to_date(to_char (created, '"+pattern+"'),'yyyy-mm') as nt, send_adaptorcode " +
			          " from "+SI_TABLE("turbo_send_cm_data")+ " where to_char (created, '"+pattern+"') = ?  group by "+
				      " to_char (created, '"+pattern+"'),send_adaptorcode ) f where a.adapter_code =f.send_adaptorcode and a.islocal = '1'"+
			          " union all "+
			          " select a.adapter_code,a.id,num,nt from  "+SI_TABLE("turbo_adapter_info")+" a , (select count (*) num, to_date(to_char (created, '"+pattern+"'),'yyyy-mm') AS nt, send_adaptorcode "+
			          " from "+SI_TABLE("turbo_send_file_data")+" where to_char (created, '"+pattern+"') = ?  group by "+
				      " to_char (created, '"+pattern+"'),send_adaptorcode ) f where a.adapter_code =f.send_adaptorcode and a.islocal = '1' ) group by adapter_code,nt,id  ";
			List<Stlonumadapterm> adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumadapterm.class, new Object[]{staDateStr,staDateStr});
			for (int i = 0; i < adapterList.size(); i++) {
				Stlonumadapterm nlist=adapterList.get(i);
				if(nlist.getNum()!=null && !nlist.getNum().isEmpty()){
					nlist.setId(UUIDGenerator.getUUID());//设置主键
					nlist.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
					nlist.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					nlist.setmTime(now);//统计时间
				}else {
					adapterList.remove(nlist);
				}
				
			}
					 
			 
			//删除staDateStr当天的量
				sql="delete from "+SI_TABLE("turbo_st_lo_num_adapter_m")+" t where t.exch_type='1' and stat_level='3' and to_char(nt,'"+pattern+"')=?";
				CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
				if (adapterList!=null && !adapterList.isEmpty()) { 
			    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
				}
			
			/**********************按照适配器统计发送 入库end **********************************/
			
		  //从最小粒度系统开始统计，包括turbo_recv_cm_data和turbo_recv_file_data表
			/**********************按照适配器统计 接收入库start **********************************/
			sql=" select adapter_code ,id as own_id,sum(num)as num ,nt from ( select a.adapter_code,a.id,num,nt " +
			          " from "+SI_TABLE("turbo_adapter_info")+" a  , (select count (*) num,  to_date(to_char (created, '"+pattern+"'),'yyyy-mm') as nt, recv_adaptorcode " +
			          " FROM "+SI_TABLE("turbo_recv_cm_data")+ " where to_char (created, '"+pattern+"') = ?  group by "+
				      " TO_CHAR (created, '"+pattern+"'),recv_adaptorcode ) f where a.adapter_code =f.recv_adaptorcode and a.islocal = '1'"+
			          " union all "+
			          " select a.adapter_code,a.id,num,nt from "+SI_TABLE("turbo_adapter_info")+" a , (select count (*) num,  to_date(to_char (created, '"+pattern+"'),'yyyy-mm') AS nt, recv_adaptorcode "+
			          " FROM "+SI_TABLE("turbo_recv_file_data")+" where to_char (created, '"+pattern+"') = ?  GROUP BY "+
				      " TO_CHAR (created, '"+pattern+"'),recv_adaptorcode ) f where a.adapter_code =f.recv_adaptorcode  and a.islocal = '1') GROUP BY adapter_code,nt,id  ";
			List<Stlonumadapterm> asysList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumadapterm.class, new Object[]{staDateStr,staDateStr});
			 
				 
			   for (int i = 0; i < asysList.size(); i++) {
					Stlonumadapterm nlist=asysList.get(i);
					if(nlist.getNum()!=null && !nlist.getNum().isEmpty()){
						nlist.setId(UUIDGenerator.getUUID());//设置主键
						nlist.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
						nlist.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
						nlist.setmTime(now);//统计时间
					}else {
						asysList.remove(nlist);
					}
					
				}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_adapter_m")+" t where t.exch_type='2' and stat_level='3' and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			if (asysList!=null && !asysList.isEmpty()) {
			   CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", asysList);
			 }
			
			/**********************按照适配器统计接收发送 入库end **********************************/
			 
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**
	 *  本节点接收发送频次(按适配器)(年)
	 * 入库表 turbo_st_lo_num_adapter_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStlonumsysyByYear(Date staDate) throws ServiceException{
		String pattern=YEAR_PATTER;
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate);
		 
		String sql=" SELECT to_date(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"') as nt,sum(num) as num ,adapter_code,EXCH_TYPE,OWN_ID "+
         " FROM "+SI_TABLE("turbo_st_lo_num_adapter_m")+" where to_char(nt,'"+pattern+"')=? "+
         " GROUP BY  to_date(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"')  ,adapter_code,EXCH_TYPE,own_id ";
		try {
			List<Stlonumadaptery> list=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumadaptery.class, new Object[]{staDateStr});
			if (list!=null && !list.isEmpty()) {
			for (Stlonumadaptery stlonumsysy : list) {
				stlonumsysy.setId(UUIDGenerator.getUUID());//设置主键
				stlonumsysy.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumsysy.setmTime(now);//统计时间
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_adapter_y")+" t where stat_level='3' and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", list);
			}
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
			
	}
	
	/**
	 *  本节点接收/发送频次(按数据分类)
	 * 入库表 turbo_st_lo_num_dtype_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStlonumdtypemByMonth(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一天的记录
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		//从最小粒度系统开始统计，包括turbo_send_cm_data和turbo_send_file_data表
		String sql="  ";
		try {
			/**********************按照适配器统计发送 入库start **********************************/
			sql=" select T1.OWN_ID,SUM(num) as num,to_date(T1.nt,'"+pattern+"') as nt,T1.data_code  from (select a.adapter_code,a.id as own_id,num, " +
					 " nt,f.send_BUSICODE as data_code from  "+SI_TABLE("turbo_adapter_info ") + " a  , ( SELECT COUNT (*) num, "+
			         " TO_CHAR (created, '"+pattern+"') AS nt, send_adaptorcode  ,send_BUSICODE FROM "+SI_TABLE("TURBO_send_FILE_DATA ")+
		             " WHERE TO_CHAR (created, '"+pattern+"') =?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_adaptorcode,send_BUSICODE ) " +
		             " f where a.adapter_code =f.send_adaptorcode "+
		             " union all "+
		             " select a.adapter_code,a.id as own_id,num,nt,f.send_BUSICODE as data_code from "+SI_TABLE("turbo_adapter_info ")+" a  , ( "+
		             " SELECT COUNT (*) num, TO_CHAR (created, '"+pattern+"') AS nt, send_adaptorcode  ,send_BUSICODE FROM "+ SI_TABLE("TURBO_send_CM_DATA ") +
		             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_adaptorcode,send_BUSICODE ) f " +
		             " where a.adapter_code =f.send_adaptorcode ) t1  GROUP BY T1.own_id,T1.nt,T1.data_code ";
			List<Stlonumdtypem> adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
			if (adapterList!=null && !adapterList.isEmpty()) {
			for (Stlonumdtypem stlonumdtypem : adapterList) {
				stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
				stlonumdtypem.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
				stlonumdtypem.setStatLevel("3");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumdtypem.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='1' and stat_level='3' and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
		    
		    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			}
			/**********************按照适配器统计发送 入库end **********************************/
			
		  //从最小粒度系统开始统计，包括turbo_recv_cm_data和turbo_recv_file_data表
			/**********************按照适配器统计 接收入库start **********************************/
			sql=" select T1.OWN_ID,SUM(num) as num,to_date(T1.nt,'"+pattern+"') as nt,T1.data_code  from (select a.adapter_code,a.id as own_id,num, " +
			 " nt,f.send_BUSICODE as data_code from  "+SI_TABLE("turbo_adapter_info") + " a  , ( SELECT COUNT (*) num, "+
	         " TO_CHAR (created, '"+pattern+"') AS nt, send_adaptorcode  ,send_BUSICODE FROM "+SI_TABLE("TURBO_recv_FILE_DATA ")+
             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_adaptorcode,send_BUSICODE ) " +
             " f where a.adapter_code =f.send_adaptorcode "+
             " union all "+
             " select a.adapter_code,a.id as own_id,num,nt,f.send_BUSICODE as data_code from "+SI_TABLE("turbo_adapter_info")+" a  , ( "+
             " SELECT COUNT (*) num, TO_CHAR (created, '"+pattern+"') AS nt, send_adaptorcode  ,send_BUSICODE FROM "+ SI_TABLE("TURBO_RECV_CM_DATA ") +
             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_adaptorcode,send_BUSICODE ) f " +
             " where a.adapter_code =f.send_adaptorcode ) t1  GROUP BY T1.own_id,T1.nt,T1.data_code ";
			adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
			 if (adapterList!=null && !adapterList.isEmpty()) {
			for (Stlonumdtypem stlonumdtypem : adapterList) {
				stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
				stlonumdtypem.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
				stlonumdtypem.setStatLevel("3");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
				stlonumdtypem.setmTime(now);//统计时间
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='2' and stat_level='3' and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			
			   CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			 }
			/**********************按照适配器统计接收发送 入库end **********************************/
			 
			 /**********************按照业务域统计发送 入库start **********************************/
			 sql=" select t4.id as own_id, data_code,sum(num) as num,to_date(nt, 'yyyy-mm') as nt"+
					 " from (select a.adapter_code, f.send_busicode as data_code, f.num, f.nt"+
					 "  from "+SI_TABLE("turbo_adapter_info")+" a,"+
					 "  (select count(*) num,"+
					 "     to_char(created, 'yyyy-mm') as nt,"+
					 "      recv_adaptorcode,"+
					 "      send_busicode"+
					 "     from "+SI_TABLE("turbo_send_cm_data")+
					 "   where to_char(created, 'yyyy-mm') = ?"+
					 "   group by to_char(created, 'yyyy-mm'),"+
					 "       recv_adaptorcode,"+
					 "        send_busicode) f"+
					 " where f.recv_adaptorcode = a.adapter_code"+
					 "  union all"+
					 "  select a.adapter_code, f.send_busicode as data_code, f.num, f.nt"+
					 "  from "+SI_TABLE("turbo_adapter_info")+" a,"+
					 "   (select count(*) num,"+
					 "   to_char(created, 'yyyy-mm') as nt,"+
					 "     recv_adaptorcode,"+
					 "  send_busicode"+
					 "   from "+SI_TABLE("turbo_send_file_data")+
					 "   where to_char(created, 'yyyy-mm') =?"+
					 "   group by to_char(created, 'yyyy-mm'),"+
					 "       recv_adaptorcode,"+
					 "       send_busicode) f"+
					 "   where f.recv_adaptorcode = a.adapter_code) t1"+
					 "  left join "+SI_TABLE("turbo_adapter_base")+" t2"+
					 "   on t1.adapter_code = t2.adapter_code"+
					 "  left join "+SI_TABLE("turbo_data_category")+" t3"+
					 "  on t2.data_code = t3.data_code"+
					 "  left join "+SI_TABLE("turbo_domain_info")+" t4"+
					 "  on t3.domain_id = t4.id"+
					 " group by t4.id, data_code, nt";
				List<Stlonumdtypem> domList=CM.getDao().listModule("按照业务域统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
				if (domList!=null && !domList.isEmpty()) {
				for (Stlonumdtypem stlonumdtypem : domList) {
					stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
					stlonumdtypem.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
					stlonumdtypem.setStatLevel("2");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					stlonumdtypem.setmTime(now);//统计时间
				}
				//删除staDateStr当天的量
				sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='1' and stat_level='2' and to_char(nt,'"+pattern+"')=?";
				CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			   
			    	CM.getDao().batchInsertModule("批量插入按照业务域统计["+staDateStr+"]的量", domList);
				}
				/**********************按照业务域统计发送 入库end **********************************/
				
			  //从最小粒度系统开始统计，包括turbo_recv_cm_data和turbo_recv_file_data表
				/**********************按照业务域统计 接收入库start **********************************/
			    sql="  select t4.id AS own_id,"+
			    		"       t1.adapter_code,"+
			    		"        data_code,"+
			    		"        sum(num) as num,"+
			    		"      to_date(nt, 'yyyy-MM') as nt"+
			    		"    from (select a.adapter_code, f.SEND_BUSICODE as data_code, f.NUM, f.NT"+
			    		"        from "+SI_TABLE("turbo_adapter_info")+" a,"+
			    		"            (select count(*) num,"+
			    		"                       to_char(created, 'yyyy-MM') as nt,"+
			    		"                      send_adaptorcode,"+
			    		"                       send_busicode"+
			    		"                 from "+SI_TABLE("turbo_recv_cm_data")+
			    		"                where to_char(created, 'yyyy-MM') = ?"+
			    		"               group by to_char(created, 'yyyy-MM'),"+
			    		"                        send_adaptorcode,"+
			    		"                        send_busicode) f"+
			    		"        where f.send_adaptorcode = a.adapter_code"+
			    		"       union all"+
			    		"      select a.adapter_code, f.send_busicode as data_code, f.num, f.nt"+
			    		"         from "+SI_TABLE("turbo_adapter_info")+" a,"+
					    "              (select count(*) num,"+
			    		"                     to_char(created, 'yyyy-MM') as nt,"+
			    		"                     send_adaptorcode,"+
			    		"                       send_busicode"+
			    		"                  from "+SI_TABLE("turbo_recv_file_data")+
			    		"                where to_char(created, 'yyyy-MM') = ?"+
			    		"              group by to_char(created, 'yyyy-MM'),"+
			    		"                        send_adaptorcode,"+
			    		"                           send_busicode) f"+
			    		"        where f.send_adaptorcode = a.adapter_code) t1"+
			    		"   left join "+SI_TABLE("turbo_adapter_base")+" t2"+
			    		"    on t1.adapter_code = t2.adapter_code"+
			    		"   left join "+SI_TABLE("turbo_data_category")+" t3"+
			    		"     on t2.data_code = t3.data_code"+
			    		"   left join "+SI_TABLE("turbo_domain_info")+" t4"+
			    		"    on t3.domain_id = t4.id"+
			    		"   group by t4.id, t1.adapter_code, t2.data_code, nt";
				domList=CM.getDao().listModule("按照业务域统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
				if (domList!=null && !domList.isEmpty()) {
				for (Stlonumdtypem stlonumdtypem : domList) {
					stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
					stlonumdtypem.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
					stlonumdtypem.setStatLevel("2");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					stlonumdtypem.setmTime(now);//统计时间
				}
				//删除staDateStr当天的量
				sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='2' and stat_level='2' and to_char(nt,'"+pattern+"')=?";
				CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
				 
				   CM.getDao().batchInsertModule("批量插入按照业务域统计["+staDateStr+"]的量", domList);
				 }
				/**********************按照业务域统计接收发送 入库end **********************************/
				 
				 /**********************按照节点统计发送 入库start **********************************/
				 sql="select T1.OWN_ID,SUM(num) as num,to_date(T1.nt,'"+pattern+"') as nt,T1.data_code  from (select node.node_CODE,node.id as own_id,num, " +
						 " nt,f.send_BUSICODE as data_code from  "+SI_TABLE("TURBO_node_INFO ") + " node  , ( SELECT COUNT (*) num, "+
				         " TO_CHAR (created, '"+pattern+"') AS nt, send_nodeCODE  ,send_BUSICODE FROM "+SI_TABLE("TURBO_send_FILE_DATA ")+
			             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_nodeCODE,send_BUSICODE ) " +
			             " f where node.node_code =f.send_nodeCODE "+
			             " union all "+
			             " select node.node_CODE,node.id as own_id,num,nt,f.send_BUSICODE as data_code from "+SI_TABLE("TURBO_node_INFO ")+" node  , ( "+
			             " SELECT COUNT (*) num, TO_CHAR (created, '"+pattern+"') AS nt, send_nodeCODE  ,send_BUSICODE FROM "+ SI_TABLE("TURBO_send_CM_DATA ") +
			             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), send_nodeCODE,send_BUSICODE ) f " +
			             " where node.node_code =f.send_nodeCODE ) t1  GROUP BY T1.own_id,T1.nt,T1.data_code ";
					List<Stlonumdtypem> nodeList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
					 if (nodeList!=null && !nodeList.isEmpty()) {
					for (Stlonumdtypem stlonumdtypem : nodeList) {
						stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
						stlonumdtypem.setExchType(AppConst.StaExchType.SEND.value());//发送，接收类型，1，发送 2接收
						stlonumdtypem.setStatLevel("1");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
						stlonumdtypem.setmTime(now);//统计时间
					}
					//删除staDateStr当天的量
					sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='1' and stat_level='1' and to_char(nt,'"+pattern+"')=?";
					CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
				   
				    	CM.getDao().batchInsertModule("批量插入按照节点统计["+staDateStr+"]的量", nodeList);
					}
					/**********************按照节点统计发送 入库end **********************************/
					
				  //从最小粒度系统开始统计，包括turbo_recv_cm_data和turbo_recv_file_data表
					/**********************按照节点统计 接收入库start **********************************/
					sql=" select T1.OWN_ID,SUM(num) as num,to_date(T1.nt,'"+pattern+"') as nt,T1.data_code  from (select node.node_CODE,node.id as own_id,num, " +
						 " nt,f.SEND_BUSICODE as data_code from  "+SI_TABLE("TURBO_node_INFO ") + " node  , ( SELECT COUNT (*) num, "+
				         " TO_CHAR (created, '"+pattern+"') AS nt, recv_nodeCODE  ,SEND_BUSICODE FROM "+SI_TABLE("TURBO_recv_FILE_DATA ")+
			             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), recv_nodeCODE,SEND_BUSICODE ) " +
			             " f where node.node_code =f.recv_nodeCODE "+
			             " union all "+
			             " select node.node_CODE,node.id as own_id,num,nt,f.SEND_BUSICODE as data_code from "+SI_TABLE("TURBO_node_INFO ")+" node  , ( "+
			             " SELECT COUNT (*) num, TO_CHAR (created, '"+pattern+"') AS nt, recv_nodeCODE  ,SEND_BUSICODE FROM "+ SI_TABLE("TURBO_RECV_CM_DATA ") +
			             " WHERE TO_CHAR (created, '"+pattern+"') = ?  GROUP BY  TO_CHAR (created, '"+pattern+"'), recv_nodeCODE,SEND_BUSICODE ) f " +
			             " where node.node_code =f.recv_nodeCODE ) t1  GROUP BY T1.own_id,T1.nt,T1.data_code ";
					nodeList=CM.getDao().listModule("按照节点统计["+staDateStr+"]的量", sql, Stlonumdtypem.class, new Object[]{staDateStr,staDateStr});
					if (nodeList!=null && !nodeList.isEmpty()) {
					for (Stlonumdtypem stlonumdtypem : nodeList) {
						stlonumdtypem.setId(UUIDGenerator.getUUID());//设置主键
						stlonumdtypem.setExchType(AppConst.StaExchType.RECV.value());//发送，接收类型，1，发送 2接收
						stlonumdtypem.setStatLevel("1");//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
						stlonumdtypem.setmTime(now);//统计时间
					}
					//删除staDateStr当天的量
					sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_m")+" t where t.exch_type='2' and stat_level='1' and to_char(nt,'"+pattern+"')=?";
					CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
					 
					   CM.getDao().batchInsertModule("批量插入按照节点统计["+staDateStr+"]的量", nodeList);
					 }
					/**********************按照节点统计接收发送 入库end **********************************/
			 
			 
			 
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**
	 * 本节点接收/发送频次(按数据分类)
	 * 入库表 turbo_st_lo_num_dtype_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStlonumdtypeyByYear(Date staDate) throws ServiceException{
		String pattern=YEAR_PATTER;
		Date now=new Date(); 
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate); 
		try {
			 
			String sql=" select to_date(to_char (nt, '"+pattern+"'),'"+pattern+"') as nt,sum(num) as num ,data_code,exch_type,own_id ,stat_level "+
			   " from "+SI_TABLE("turbo_st_lo_num_dtype_m")+"  where to_char(nt,'"+pattern+"')=? "+
			   "  group by to_date(to_char (nt, '"+pattern+"'),'"+pattern+"') ,data_code,exch_type,own_id,stat_level ";
			List<Stlonumdtypey> list=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stlonumdtypey.class, new Object[]{staDateStr});
			for (Stlonumdtypey stlonumdtypey : list) {
				stlonumdtypey.setId(UUIDGenerator.getUUID());//设置主键 
				stlonumdtypey.setmTime(now);//统计时间
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_lo_num_dtype_y")+" t where  to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			if (list!=null && !list.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", list);
			} 
		} catch (DaoException e) {
			throw new ServiceException(e);
		}			
	}
	/**
	 *  节点间交换频次（月）
	 *  一个月存入一条记录
	 *  按月分组
	 * 入库表 turbo_st_bt_node_num_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者：樊晓晓
	 */
	public void statStBtNodeNummByMonth(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		String sql=null;
		try {
		 /**************************按照节点统计级别      入库 start******************************/		          
			  sql=  "select te1.from_id, te1.to_id, te1.nt,"+
		                     " case when te1.from_num is null then 0 else te1.from_num end from_num,"+
					         " case when te2.to_num is null then 0 else te2.to_num end to_num "+
		                " from "+
				        "("+
						"  select to_date(nt,'"+pattern+"') nt,t2.id from_id,t3.id to_id,from_num " +
				  		"   from "+
					    "   (" +
						"   select nt,send_nodecode,recv_nodecode,sum(from_num) from_num from "+
					    "     ("+
					    "     select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) from_num from "+SI_TABLE("turbo_send_cm_data")+
					    " 	  where to_char(created,'"+pattern+"')=? "+
					    " 	  group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode "+
					    " 	  union all " +
					    "     select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) from_num from "+SI_TABLE("turbo_send_file_data")+
					    "     where to_char(created,'"+pattern+"')=? " +
					    "     group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode" +
					    "     ) group by nt,send_nodecode,recv_nodecode "+
					    "   ) t1 " + 
					    "   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
				        "   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code"+
					    " ) te1 "+
					    " full outer join"+
						"("+
						"   select to_date(nt,'"+pattern+"') nt,t33.id from_id,t22.id to_id, to_num  " +
							"   from "+
						"  (" +
							  " select nt,recv_nodecode,send_nodecode,sum(to_num) to_num from "+
						"     ("+
						"     select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) to_num from "+SI_TABLE("turbo_recv_cm_data")+
						"     where to_char(created,'"+pattern+"')=? "+
						"     group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode "+
						"     union all " +
						"     select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) to_num from "+SI_TABLE("turbo_recv_file_data")+
						"     where to_char(created,'"+pattern+"')=? " +
						"     group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode" +
						"     ) group by nt,recv_nodecode,send_nodecode "+
						"  ) t11 " +
						"   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t22 on t11.send_nodecode=t22.node_code"+
						"   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t33 on t11.recv_nodecode=t33.node_code"+
						") te2  "+
					    "    on te1.from_id=te2.from_id and te1.to_id=te2.to_id and te1.nt=te2.nt";
		  List<StBtNodeNumm> sendList=CM.getDao().listModule("按照节点统计级别统计["+staDateStr+"]的量", sql, StBtNodeNumm.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
			for (StBtNodeNumm stBtNodeNumm : sendList) {
				stBtNodeNumm.setId(UUIDGenerator.getUUID());//设置主键
				stBtNodeNumm.setStatLevel(AppConst.StatLevel.NODE.value());//
				stBtNodeNumm.setmTime(now);//统计时间
			}
		   //删除staDateStr当月的量
		   sql="delete from "+SI_TABLE("turbo_st_bt_node_num_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
		   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.NODE.value(),staDateStr});
		  if (sendList!=null && !sendList.isEmpty()) {
			  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
		   }
		   /********************** 按照节点统计级别  类型 end *****************************************/
		   
		  
			   /**************************按照适配器统计级别      入库 start******************************/		          
		  sql=    "select  case when te1.from_id is null then te2.from_id else te1.from_id end from_id , case when te1.to_id is null then te2.to_id else te1.to_id end to_id , te1.nt ,"+
				        " case when te1.from_num is null then 0 else te1.from_num end from_num,"+
			            " case when te2.to_num is null then 0 else te2.to_num end to_num "+
				    " from "+    
		    		"("+
		    		"   select t2.id from_id , from_num , t3.id to_id , to_date(nt,'"+pattern+"') nt" +
					"    from " +
		    		"  ("+
		    		"     select send_adaptorcode,recv_adaptorcode,sum(from_num) from_num,nt from"+
					"     (" +				
					"        select count(*) from_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_send_cm_data")+" where to_char(created,'"+pattern+"')=?  "+
	                "        group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
	                "      union all " +
	                "        select count(*) from_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_send_file_data")+" where to_char(created,'"+pattern+"')=? "+
	                "        group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
					"      ) " +
					"    group by nt,send_adaptorcode,recv_adaptorcode"+
					"   ) t1"+
		            "    inner join "+SI_TABLE("turbo_adapter_info")+"   t2 on t2.adapter_code=t1.send_adaptorcode and t2.islocal = '1'" +
			        "    inner join "+SI_TABLE("turbo_adapter_info")+"   t3 on t3.adapter_code=t1.recv_adaptorcode  and t3.islocal = '0'" +
		            ") te1"+
		            " full outer join "+
			        "("+
					"   select t33.id from_id , to_num , t22.id to_id , to_date(nt,'"+pattern+"') nt" +
					"    from " +
					"  ("+
					"     select send_adaptorcode,recv_adaptorcode,sum(to_num) to_num,nt from"+
					"     (" +				
					"      select count(*) to_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_recv_cm_data")+" where to_char(created,'"+pattern+"')=?  "+
					"      group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
					"      union all " +
					"      select count(*) to_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_recv_file_data")+" where to_char(created,'"+pattern+"')=? "+
					"      group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
					"      ) " +
					"   group by nt,send_adaptorcode,recv_adaptorcode"+
					"  ) t11"+
					"    inner join "+SI_TABLE("turbo_adapter_info")+"   t22 on t22.adapter_code=t11.send_adaptorcode and t22.islocal = '1'" +
					"    inner join "+SI_TABLE("turbo_adapter_info")+"   t33 on t33.adapter_code=t11.recv_adaptorcode and t33.islocal = '0'" + 
					") te2"+
					"     on te1.from_id=te2.to_id and te1.to_id=te2.from_id and te1.nt=te2.nt";
				  List<StBtNodeNumm> sendSysList=CM.getDao().listModule("按照系统统计级别统计["+staDateStr+"]的量", sql, StBtNodeNumm.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
					for (StBtNodeNumm stBtNodeNumm : sendSysList) {
						stBtNodeNumm.setId(UUIDGenerator.getUUID());//设置主键
						stBtNodeNumm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//
						stBtNodeNumm.setmTime(now);//统计时间
					}
				   //删除staDateStr当月的量
				   sql="delete from "+SI_TABLE("turbo_st_bt_node_num_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
				   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.ADAPTER.value(),staDateStr});
				  if (sendSysList!=null && !sendSysList.isEmpty()) {
					  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendSysList);
				}
				   /********************** 按照系统统计级别  类型 end *****************************************/
				   
				  
				} catch (DaoException e) {
					throw new ServiceException(e);
		      }		
	}
	/**
	 *  节点间交换频次（年）
	 *  一年存入一条记录
	 *  按年分组
	 * 入库表 turbo_st_bt_node_num_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者：樊晓晓
	 */
	public void statStBtNodeNumyByYear(Date staDate) throws ServiceException{
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=YEAR_PATTER;
		String sql=null;
		try {
			 /**************************按照节点统计级别      入库 start******************************/		          
			 sql=   "select te1.from_id , te1.to_id , te1.nt ,"+
				        " case when te1.from_num is null then 0 else te1.from_num end from_num,"+
			            " case when te2.to_num is null then 0 else te2.to_num end to_num "+
				    " from "+    
			        "("+
					"  select to_date(nt,'"+pattern+"') nt,t2.id from_id,t3.id to_id,from_num " +
			  		"   from "+
				    "   (" +
					"   select nt,send_nodecode,recv_nodecode,sum(from_num) from_num from "+
				    "     ("+
				    "     select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) from_num from "+SI_TABLE("turbo_send_cm_data")+
				    " 	  where to_char(created,'"+pattern+"')=? "+
				    " 	  group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode "+
				    " 	  union all " +
				    "     select to_char(created,'"+pattern+"') nt,send_nodecode,recv_nodecode,count(*) from_num from "+SI_TABLE("turbo_send_file_data")+
				    "     where to_char(created,'"+pattern+"')=? " +
				    "     group by to_char(created,'"+pattern+"'),send_nodecode,recv_nodecode" +
				    "     ) group by nt,send_nodecode,recv_nodecode "+
				    "   ) t1 " + 
				    "   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t2 on t1.send_nodecode=t2.node_code"+
			        "   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t3 on t1.recv_nodecode=t3.node_code"+
				    ") te1 "+
				" full outer join"+
					"("+
					"  select to_date(nt,'"+pattern+"') nt,t33.id from_id,t22.id to_id, to_num  " +
						"   from "+
					"  (" +
					"   select nt,recv_nodecode,send_nodecode,sum(to_num) to_num from "+
					"     ("+
					"     select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) to_num from "+SI_TABLE("turbo_recv_cm_data")+
					"     where to_char(created,'"+pattern+"')=? "+
					"     group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode "+
					"     union all " +
					"     select to_char(created,'"+pattern+"') nt,recv_nodecode,send_nodecode,count(*) to_num from "+SI_TABLE("turbo_recv_file_data")+
					"     where to_char(created,'"+pattern+"')=? " +
					"     group by to_char(created,'"+pattern+"'),recv_nodecode,send_nodecode" +
					"     ) group by nt,recv_nodecode,send_nodecode "+
					"  ) t11 " +
					"   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t22 on t11.send_nodecode=t22.node_code"+
					"   inner join "+SI_TABLE("TURBO_NODE_INFO")+" t33 on t11.recv_nodecode=t33.node_code"+
					") te2  "+
				    "    on te1.from_id=te2.from_id and te1.to_id=te2.to_id and te1.nt=te2.nt";
			  List<StBtNodeNumy> sendList=CM.getDao().listModule("按照节点统计级别统计["+staDateStr+"]的量", sql, StBtNodeNumy.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
				for (StBtNodeNumy stBtNodeNumy : sendList) {
					stBtNodeNumy.setId(UUIDGenerator.getUUID());//设置主键
					stBtNodeNumy.setStatLevel(AppConst.StatLevel.NODE.value());//
					stBtNodeNumy.setmTime(now);//统计时间
				}
			   //删除staDateStr当月的量
			   sql="delete from "+SI_TABLE("turbo_st_bt_node_num_y")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.NODE.value(),staDateStr});
			  if (sendList!=null && !sendList.isEmpty()) {
				  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendList);
			}
			   /********************** 按照节点统计级别   类型 end *****************************************/
			   
			 
				   /**************************按照系统统计级别      入库 start******************************/		          
					  sql=  "select te1.from_id , te1.to_id , te1.nt ,"+
						        " case when te1.from_num is null then 0 else te1.from_num end from_num,"+
					            " case when te2.to_num is null then 0 else te2.to_num end to_num "+
						    " from "+    
				    		"("+
				    		"   select t2.id from_id , from_num , t3.id to_id , to_date(nt,'"+pattern+"') nt" +
							"    from " +
				    		"  ("+
				    		"     select send_adaptorcode,recv_adaptorcode,sum(from_num) from_num,nt from"+
							"     (" +				
							"     select count(*) from_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_send_cm_data")+" where to_char(created,'"+pattern+"')=?  "+
			                "     group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
			                "     union all " +
			                "     select count(*) from_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_send_file_data")+" where to_char(created,'"+pattern+"')=? "+
			                "     group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
							"      ) " +
							"    group by nt,send_adaptorcode,recv_adaptorcode"+
							"   ) t1"+
				            "    inner join "+SI_TABLE("turbo_adapter_base")+"   t2 on t2.adapter_code=t1.send_adaptorcode" +
					        "    inner join "+SI_TABLE("turbo_adapter_base")+"   t3 on t3.adapter_code=t1.recv_adaptorcode" +
				            ") te1"+
				          " full outer join "+
					        "("+
							"   select t33.id from_id , to_num , t22.id to_id , to_date(nt,'"+pattern+"') nt" +
							"    from " +
							"  ("+
							"     select send_adaptorcode,recv_adaptorcode,sum(to_num) to_num,nt from"+
							"     (" +				
							"     select count(*) to_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_recv_cm_data")+" where to_char(created,'"+pattern+"')=?  "+
							"     group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
							"     union all " +
							"     select count(*) to_num,to_char(created,'"+pattern+"') as nt,send_adaptorcode,recv_adaptorcode from "+SI_TABLE("turbo_recv_file_data")+" where to_char(created,'"+pattern+"')=? "+
							"     group by to_char(created,'"+pattern+"'),send_adaptorcode,recv_adaptorcode " +
							"      ) " +
							"   group by nt,send_adaptorcode,recv_adaptorcode"+
							"  ) t11"+
							"    inner join "+SI_TABLE("turbo_adapter_base")+"   t22 on t22.adapter_code=t11.send_adaptorcode" +
							"    inner join "+SI_TABLE("turbo_adapter_base")+"   t33 on t33.adapter_code=t11.recv_adaptorcode" + 
							") te2"+
							"     on te1.from_id=te2.from_id and te1.to_id=te2.to_id and te1.nt=te2.nt";
					  List<StBtNodeNumy> sendSysList=CM.getDao().listModule("按照系统统计级别统计["+staDateStr+"]的量", sql, StBtNodeNumy.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
						for (StBtNodeNumy stBtNodeNumy : sendSysList) {
							stBtNodeNumy.setId(UUIDGenerator.getUUID());//设置主键
							stBtNodeNumy.setStatLevel(AppConst.StatLevel.ADAPTER.value());//
							stBtNodeNumy.setmTime(now);//统计时间
						}
					   //删除staDateStr当月的量
					   sql="delete from "+SI_TABLE("turbo_st_bt_node_num_y")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
					   CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.ADAPTER.value(),staDateStr});
					  if (sendSysList!=null && !sendSysList.isEmpty()) {
						  CM.getDao().batchInsertModule("批量插入按照统计["+staDateStr+"]的量", sendSysList);
					}
			
				  } catch (DaoException e) {
						throw new ServiceException(e);
			      }		
	}
	/**
	 * 管理节点-内外网交换频次(月)
	 * 按天分组，每天统计一次
	 * 入库表 turbo_st_bt_net_top_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:何鹏
	 */
	public void statStbtnettopmByDay(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,统计天的记录
		Date now=new Date();
		SimpleDateFormat sdfs=new SimpleDateFormat(DAY_PATTERN);
		String staDateStr=sdfs.format(staDate);
		String pattern=DAY_PATTERN;
		//按系统
		String sql=
				"select to_date(nt,'"+pattern+"') nt,  to_num,  from_num, " + 
						"       case " + 
						"         when s1.id is null then " + 
						"          from_id " + 
						"         else " + 
						"          s1.id " + 
						"       end from_id, " + 
						"       case " + 
						"         when s2.id is null then " + 
						"          to_id " + 
						"         else " + 
						"          s2.id " + 
						"       end to_id " + 
						"  from (select case " + 
						"                 when t1.nt is null then " + 
						"                  to_char(t2.nt, '"+pattern+"') " + 
						"                 else " + 
						"                  to_char(t1.nt, '"+pattern+"') " + 
						"               end nt, " + 
						"               case " + 
						"                 when t1.from_id is null then " + 
						"                  t2.from_id " + 
						"                 else " + 
						"                  t1.from_id " + 
						"               end from_id, " + 
						"               case " + 
						"                 when t1.to_id is null then " + 
						"                  t2.to_id " + 
						"                 else " + 
						"                  t1.to_id " + 
						"               end to_id, " + 
						"               case" + 
						"                 when t1.from_num is null then " + 
						"                  0 " + 
						"                 else " + 
						"                  t1.from_num " + 
						"               end from_num, " + 
						"               case" + 
						"                 when t2.to_num is null then " + 
						"                  0 " + 
						"                 else " + 
						"                  t2.to_num " + 
						"               end to_num " + 
						"          from (select send_adaptorcode from_id, " + 
						"                       recv_adaptorcode to_id, " + 
						"                       to_date(to_char(created, '"+pattern+"'), '"+pattern+"') nt, " + 
						"                       COUNT(*) from_num " + 
						"                  from (select send_adaptorcode, recv_adaptorcode, created " + 
						"                          from "+SI_TABLE("turbo_send_cm_data")+" " + 
						"                         where cross_net != '0' " + 
						"                        union all " + 
						"                        select send_adaptorcode, recv_adaptorcode, created " + 
						"                          from "+SI_TABLE("turbo_send_file_data")+" " + 
						"                         where cross_net != '0') " + 
						"                 group by send_adaptorcode, " + 
						"                          recv_adaptorcode, " + 
						"                          to_char(created, '"+pattern+"')) t1 " + 
						"          full outer join (select send_adaptorcode to_id, " + 
						"                                 recv_adaptorcode from_id, " + 
						"                                 to_date(to_char(created, '"+pattern+"'), " + 
						"                                         '"+pattern+"') nt, " + 
						"                                 COUNT(*) to_num " + 
						"                            from (select send_adaptorcode, recv_adaptorcode, created " + 
						"                                    from "+SI_TABLE("turbo_recv_cm_data")+" " + 
						"                                   where cross_net != '0' " + 
						"                                  union all " + 
						"                                  select send_adaptorcode, recv_adaptorcode, created " + 
						"                                    from "+SI_TABLE("turbo_recv_file_data")+" " + 
						"                                   where cross_net != '0') " + 
						"                           group by send_adaptorcode, " + 
						"                                    recv_adaptorcode, " + 
						"                                    to_char(created, '"+pattern+"')) t2 " + 
						"            on t1.from_id = t2.from_id " + 
						"           and t1.to_id = t2.to_id " + 
						"           and t1.nt = t2.nt) tt1 " + 
						"  left join "+SI_TABLE("turbo_adapter_base")+" s1 " + 
						"    on tt1.from_id = s1.adapter_code " + 
						"  left join "+SI_TABLE("turbo_adapter_base")+" s2 " + 
						"    on tt1.to_id = s2.adapter_code" +
						" where nt=? ";
		try {
			List<Stbtnettopm> adapterList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stbtnettopm.class, new Object[]{staDateStr});
			if(adapterList.size()!=0){
				for (Stbtnettopm stbtnettopm : adapterList) {
					stbtnettopm.setId(UUIDGenerator.getUUID());//设置主键
					stbtnettopm.setStatLevel(AppConst.StatLevel.ADAPTER.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					stbtnettopm.setmTime(now);//统计时间
				}
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_bt_net_top_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.ADAPTER.value(),staDateStr});
		    if (adapterList!=null && !adapterList.isEmpty()) {
		    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", adapterList);
			}
			
		  //节点
			sql=
					"select to_date(nt,'"+pattern+"') nt, " +
							"       to_num, " + 
							"       from_num, " + 
							"       case " + 
							"         when s1.id is null then " + 
							"          from_id " + 
							"         else " + 
							"          s1.id " + 
							"       end from_id, " + 
							"       case " + 
							"         when s2.id is null then " + 
							"          to_id " + 
							"         else " + 
							"          s2.id " + 
							"       end to_id " + 
							"  from (select case " + 
							"                 when t1.nt is null then " + 
							"                  to_char(t2.nt, '"+pattern+"') " + 
							"                 else " + 
							"                  to_char(t1.nt, '"+pattern+"') " + 
							"               end nt, " + 
							"               case " + 
							"                 when t1.from_id is null then " + 
							"                  t2.from_id " + 
							"                 else " + 
							"                  t1.from_id " + 
							"               end from_id, " + 
							"               case " + 
							"                 when t1.to_id is null then " + 
							"                  t2.to_id " + 
							"                 else " + 
							"                  t1.to_id " + 
							"               end to_id, " + 
							"               case" + 
							"                 when t1.from_num is null then " + 
							"                  0 " + 
							"                 else " + 
							"                  t1.from_num " + 
							"               end from_num, " + 
							"               case" + 
							"                 when t2.to_num is null then " + 
							"                  0 " + 
							"                 else " + 
							"                  t2.to_num " + 
							"               end to_num " + 
							"          from (select send_nodecode from_id, " + 
							"                       recv_nodecode to_id, " + 
							"                       to_date(to_char(created, '"+pattern+"'), '"+pattern+"') nt, " + 
							"                       COUNT(*) from_num " + 
							"                  from (select send_nodecode, recv_nodecode, created " + 
							"                          from "+SI_TABLE("turbo_send_cm_data")+" " + 
							"                         where cross_net != '0' " + 
							"                        union all " + 
							"                        select send_nodecode, recv_nodecode, created " + 
							"                          from "+SI_TABLE("turbo_send_file_data")+" " + 
							"                         where cross_net != '0') " + 
							"                 group by send_nodecode, " + 
							"                          recv_nodecode, " + 
							"                          to_char(created, '"+pattern+"')) t1 " + 
							"          full outer join (select send_nodecode to_id, " + 
							"                                 recv_nodecode from_id, " + 
							"                                 to_date(to_char(created, '"+pattern+"'), " + 
							"                                         '"+pattern+"') nt, " + 
							"                                 COUNT(*) to_num " + 
							"                            from (select send_nodecode, recv_nodecode, created " + 
							"                                    from "+SI_TABLE("turbo_recv_cm_data")+" " + 
							"                                   where cross_net != '0' " + 
							"                                  union all " + 
							"                                  select send_nodecode, recv_nodecode, created " + 
							"                                    from "+SI_TABLE("turbo_recv_file_data")+" " + 
							"                                   where cross_net != '0') " + 
							"                           group by send_nodecode, " + 
							"                                    recv_nodecode, " + 
							"                                    to_char(created, '"+pattern+"')) t2 " + 
							"            on t1.from_id = t2.from_id " + 
							"           and t1.to_id = t2.to_id " + 
							"           and t1.nt = t2.nt) tt1 " + 
							"  left join "+SI_TABLE("turbo_node_info")+" s1 " + 
							"    on tt1.from_id = s1.node_code " + 
							"  left join "+SI_TABLE("turbo_node_info")+" s2 " + 
							"    on tt1.to_id = s2.node_code" +
							" where nt=? ";
			List<Stbtnettopm> nodeList=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stbtnettopm.class, new Object[]{staDateStr});
			if(nodeList.size()!=0){
				for (Stbtnettopm stbtnettopm : nodeList) {
					stbtnettopm.setId(UUIDGenerator.getUUID());//设置主键
					stbtnettopm.setStatLevel(AppConst.StatLevel.NODE.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					stbtnettopm.setmTime(now);//统计时间
				}
			}
			//删除staDateStr当天的量
			sql="delete from "+SI_TABLE("turbo_st_bt_net_top_m")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除["+staDateStr+"]的发送数据统计", sql, new Object[]{AppConst.StatLevel.NODE.value(),staDateStr});
		    if (nodeList!=null && !nodeList.isEmpty()) {
		    	CM.getDao().batchInsertModule("批量插入按照适配器统计["+staDateStr+"]的量", nodeList);
			}
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	private void statStbtnettopmByMonth(String staDateStr,String pattern,Date now,AppConst.StatLevel level) throws DaoException{
		String sql=" select from_id,sum(from_num) from_num,to_id,sum(to_num) to_num,to_date(to_char(nt,'"+pattern+"'),'"+pattern+"') nt "+
				            " from "+SI_TABLE("turbo_st_bt_net_top_m")+
							" where to_char(nt,'"+pattern+"')=? and  stat_level=?"+
							" group by to_char(nt,'"+pattern+"'),from_id,to_id";
			List<Stbtnettopy> list=CM.getDao().listModule("按照适配器统计["+staDateStr+"]的量", sql, Stbtnettopy.class, new Object[]{staDateStr,level.value()});
			if(list.size()!=0){
				for (Stbtnettopy stbtnettopy : list) {
					stbtnettopy.setId(UUIDGenerator.getUUID());//设置主键
					stbtnettopy.setStatLevel(level.value());//系统 统计级别  统计级别： 1 节点 2 业务域 3 系统
					stbtnettopy.setmTime(now);//统计时间
				}
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_net_top_y")+" t where stat_level=? and to_char(nt,'"+pattern+"')=?";
			CM.getDao().delete("删除按照"+level.getDesc()+"["+staDateStr+"]的发送数据统计", sql, new Object[]{level.value(),staDateStr});
			if (list!=null && !list.isEmpty()) {
				CM.getDao().batchInsertModule("批量插入按照"+level.getDesc()+"统计["+staDateStr+"]的量", list);
			}
	}
	
	/**
	 * 管理节点-内外网交换频次(年)
	 * 按月分组，每月统计一次
	 * 入库表 turbo_st_bt_net_top_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:何鹏
	 */
	public void statStbtnettopmByMonth(Date staDate) throws ServiceException{
		//获取要统计的日期字符串,就是要统计哪一个月
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		String pattern=MONTH_PATTER;
		try {
		/**********************按照适配器统计 入库start **********************************/
		statStbtnettopmByMonth(staDateStr, pattern, now, AppConst.StatLevel.ADAPTER);
		/**********************按照适配器统计入库end **********************************/
		
		/**********************按照节点统计 入库start **********************************/
		statStbtnettopmByMonth(staDateStr, pattern, now, AppConst.StatLevel.NODE);
		/**********************按照节点统计 入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
	}
	
	/**
	 * 节点/系统注册频次 
	 * 入库表 turbo_st_bt_reg_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStbtregyByMonth(Date staDate) throws ServiceException{
		String pattern=MONTH_PATTER;
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		try {
			/**********************按照节点  入库start **********************************/
			String sql=" SELECT count(*) num  FROM "+SI_TABLE("turbo_node_info")+"  A LEFT JOIN "+SI_TABLE("turbo_node_info")+" b ON A.ID = b.pid "+
                       " WHERE a.islocal='0' and   to_char(a.mtime,'"+pattern+"')= ?  ";
			List<Stbtregy> list=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtregy.class, new Object[]{staDateStr});
			for (Stbtregy stbtregy : list) {
				stbtregy.setId(UUIDGenerator.getUUID());//设置主键 
				stbtregy.setRegType("1");//注册对象类型1 节点 2 系统
				stbtregy.setmTime(now);//统计时间
				stbtregy.setNt(staDate);
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_reg_y")+"  where  to_char(nt,'"+pattern+"')= ? and reg_Type='1'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			 
			CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", list);
			
			/**********************按照节点  入库end **********************************/
			
			/**********************按照系统  入库start **********************************/
			sql="  select count(*) num from "+ SI_TABLE("turbo_adapter_info")+"  a left join "+SI_TABLE("turbo_node_info")+"  b on  a.node_code  = b.node_code "+
                " WHERE to_char(a.mtime,'"+pattern+"')= ? ";
			List<Stbtregy> nlist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtregy.class, new Object[]{staDateStr});
			for (Stbtregy stbtregy : nlist) {
				stbtregy.setId(UUIDGenerator.getUUID());//设置主键 
				stbtregy.setRegType("2");//注册对象类型1 节点 2 系统
				stbtregy.setmTime(now);//统计时间
				stbtregy.setNt(staDate);
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_reg_y")+"  where  to_char(nt,'"+pattern+"')=? and REG_Type='2'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			 
			CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", nlist);
			 
			/**********************按照系统  入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
			
	}
	
	/**
	 * 交换频率最高的业务数据
	 * 入库表 turbo_st_bt_dt_top_m
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStbtdttopmByMonth(Date staDate) throws ServiceException{
		String pattern=MONTH_PATTER;
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(MONTH_PATTER);
		String staDateStr=sdf.format(staDate);
		try {
			/**********************按照内外网  入库start **********************************/
			String sql=" select b.data_code,a.num ,to_date(A .nt,'"+pattern+"') as nt from ( " +
				 "  select count(*)num ,data_code ,nt from (SELECT  send_BUSICODE as data_code, "+
                 " to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_RECV_CM_DATA")+" WHERE CROSS_NET != '0' " +
                 " AND to_char(CREATED,'"+pattern+"')= ? "+ 
                 " union all "+
                 " SELECT  send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_RECV_FILE_DATA")+
	             " where CROSS_NET != '0' AND to_char(CREATED,'"+pattern+"')= ? "+
                 " union all " +
                 " SELECT send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_send_CM_DATA")+
                 " WHERE CROSS_NET != '0' AND to_char(CREATED,'"+pattern+"')= ? "+
                 " union all "+
                 " SELECT  send_BUSICODE as data_code, to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_SEND_FILE_DATA")+
                 " WHERE CROSS_NET != '0' AND to_char(CREATED,'"+pattern+"')= ?  ) " +
                 " GROUP by data_code,nt) a,"+SI_TABLE("TURBO_DATA_CATEGORY")+" b where a.data_code =b.DATA_CODE ";
			List<Stbtdttopm> inlist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopm.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
			if(inlist!=null && !inlist.isEmpty()){ 
			for (Stbtdttopm stbtdttopm : inlist) {
				stbtdttopm.setId(UUIDGenerator.getUUID());//设置主键 
				/* stbtdttopm.setFrom_node_id("37dfeba693ff4f74bf9050c1edc3e324");//占位
				 stbtdttopm.setTo_node_id("e4023ad5aea7425aab636203bdfd8993");//占位
*/				 stbtdttopm.setStatLevel("1"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopm.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_m")+"  where  to_char(nt,'"+pattern+"')= ? and stat_level='1'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", inlist);
			
			}
			/**********************按照内外网  入库end **********************************/
			
			/**********************按照管理范围  入库start **********************************/
			sql= " select b.data_code,a.num , to_date(A .nt,'"+pattern+"') as nt from ( " +
				 "  select count(*)num ,data_code ,nt from ( " +
				 "SELECT  send_BUSICODE as data_code,  to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_RECV_CM_DATA")+
				 " WHERE   to_char(CREATED,'"+pattern+"')= ? "+ 
                 " union all "+
                 " SELECT  send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_RECV_FILE_DATA")+
	             " where  to_char(CREATED,'"+pattern+"')= ? "+
                 " union all " +
                 " SELECT send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_send_CM_DATA")+
                 " WHERE   to_char(CREATED,'"+pattern+"')= ? "+
                 " union all "+
                 " SELECT  send_BUSICODE as data_code, to_char(CREATED,'"+pattern+"') as nt FROM "+SI_TABLE("TURBO_SEND_FILE_DATA")+
                 " WHERE  to_char(CREATED,'"+pattern+"')= ?  ) " +
                 " GROUP by data_code,nt) a,"+SI_TABLE("TURBO_DATA_CATEGORY")+" b where a.data_code =b.DATA_CODE "; 
			List<Stbtdttopm> malist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopm.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
			if(malist!=null && !malist.isEmpty()){
			for (Stbtdttopm stbtdttopm : malist) {
				stbtdttopm.setId(UUIDGenerator.getUUID());//设置主键 
				/* stbtdttopm.setFrom_node_id("37dfeba693ff4f74bf9050c1edc3e324");//占位
				 stbtdttopm.setTo_node_id("e4023ad5aea7425aab636203bdfd8993");//占位
*/				 stbtdttopm.setStatLevel("2"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopm.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_m")+"  where  to_char(nt,'"+pattern+"')=? and stat_level='2'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			 
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", malist);
			}
			/**********************按照管理范围   入库end **********************************/
		
            /**********************按照节点间  入库start **********************************/
			
			sql=" select case when b.id is null then a.data_code else b.data_code end as data_code," +
					" case when na.id is null then a.send_nodecode else na.id end as from_node_id, " +
					" case when nb.id is null then a.recv_nodecode else nb.id end as to_node_id, " +
					" a.num ,to_date(A .nt,'"+pattern+"') as nt from ( " +
				 "  select count(*)num ,data_code ,nt ,send_nodecode,recv_nodecode from (SELECT  send_BUSICODE as data_code, "+
                 " to_char(CREATED,'"+pattern+"') as nt ,send_nodecode,recv_nodecode FROM "+SI_TABLE("TURBO_RECV_CM_DATA")+" WHERE to_char(CREATED,'"+pattern+"')= ? "+ 
                 " union all "+
                 " SELECT  send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt,send_nodecode,recv_nodecode FROM "+SI_TABLE("TURBO_RECV_FILE_DATA")+
	             " where to_char(CREATED,'"+pattern+"')= ? "+
                 " union all " +
                 " SELECT send_BUSICODE as data_code,to_char(CREATED,'"+pattern+"') as nt,send_nodecode,recv_nodecode FROM "+SI_TABLE("TURBO_send_CM_DATA")+
                 " WHERE  to_char(CREATED,'"+pattern+"')= ? "+
                 " union all "+
                 " SELECT  send_BUSICODE as data_code, to_char(CREATED,'"+pattern+"') as nt,send_nodecode,recv_nodecode FROM "+SI_TABLE("TURBO_SEND_FILE_DATA")+
                 " WHERE    to_char(CREATED,'"+pattern+"')= ?  ) " +
                 " GROUP by send_nodecode,recv_nodecode,data_code,nt) a" +
                 " left join "+SI_TABLE("TURBO_DATA_CATEGORY")+" b on a.data_code =b.DATA_CODE " +
                 " left join "+SI_TABLE("turbo_node_info")+" na on na.node_code=a.send_nodecode " +
                 " left join "+SI_TABLE("turbo_node_info")+" nb on nb.node_code=a.recv_nodecode ";
			List<Stbtdttopm> ndlist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopm.class, new Object[]{staDateStr,staDateStr,staDateStr,staDateStr});
			if(ndlist!=null && !ndlist.isEmpty()){
			for (Stbtdttopm stbtdttopm : ndlist) {
				stbtdttopm.setId(UUIDGenerator.getUUID());//设置主键  
				 stbtdttopm.setStatLevel("3"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopm.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_m")+"  where  to_char(nt,'"+pattern+"')=? and stat_level='3'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			 
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", ndlist);
			
			}
			
			/**********************按照节点间  入库end **********************************/
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
			
	}
	
	/**
	 * 交换频率最高的业务数据
	 * 入库表 turbo_st_bt_dt_top_y
	 * @param staDate  统计日期
	 * @throws ServiceException 
	 * @作者:古玉龙
	 */
	public void statStbtdttopmByYear(Date staDate) throws ServiceException{
		String pattern=YEAR_PATTER;
		Date now=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat(YEAR_PATTER);
		String staDateStr=sdf.format(staDate);
		try {
			/**********************按照内外网  入库start **********************************/
			String sql=" select sum(num) as num ,data_code,TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"')  as nt from "+SI_TABLE("TURBO_ST_BT_DT_TOP_M")+
					" where STAT_LEVEL='1' and to_char(nt,'"+pattern+"')=?  GROUP BY data_code,TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"') ";
			List<Stbtdttopy> inlist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopy.class, new Object[]{staDateStr});
			if(inlist!=null && !inlist.isEmpty()){
			for (Stbtdttopy stbtdttopy : inlist) {
				stbtdttopy.setId(UUIDGenerator.getUUID());//设置主键 
				/*stbtdttopy.setFrom_node_id("37dfeba693ff4f74bf9050c1edc3e324");//占位
				stbtdttopy.setTo_node_id("e4023ad5aea7425aab636203bdfd8993");//占位
*/				stbtdttopy.setStatLevel("1"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopy.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_y")+"  where  to_char(nt,'"+pattern+"')= ? and stat_level='1'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", inlist);
			 }
			/**********************按照内外网  入库end **********************************/
			
			/**********************按照管理范围  入库start **********************************/
			sql=" select sum(num) as num ,data_code,TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"') as nt from "+SI_TABLE("TURBO_ST_BT_DT_TOP_M")+
					" where STAT_LEVEL='2' and to_char(nt,'"+pattern+"')=?  GROUP BY data_code,TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"') ";
			List<Stbtdttopy> malist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopy.class, new Object[]{staDateStr});
			if (malist!=null && !malist.isEmpty()) {
			for (Stbtdttopy stbtdttopy : malist) {
				stbtdttopy.setId(UUIDGenerator.getUUID());//设置主键 
			/*	stbtdttopy.setFrom_node_id("37dfeba693ff4f74bf9050c1edc3e324");//占位
				stbtdttopy.setTo_node_id("e4023ad5aea7425aab636203bdfd8993");//占位
*/				stbtdttopy.setStatLevel("2"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopy.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_y")+"  where  to_char(nt,'"+pattern+"')=? and stat_level='2'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			
			CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", malist);
			}
			/**********************按照管理范围   入库end **********************************/
			
			/**********************按照节点间  入库start **********************************/
			sql=" SELECT SUM (num) AS num, data_code, FROM_NODE_ID, TO_NODE_ID,TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"') AS nt "+
                " FROM "+SI_TABLE("TURBO_ST_BT_DT_TOP_M")+" WHERE STAT_LEVEL = '3' AND TO_CHAR (nt, '"+pattern+"') = ? "+
                " GROUP BY data_code,FROM_NODE_ID,TO_NODE_ID , TO_DATE(TO_CHAR (nt, '"+pattern+"'),'"+pattern+"')";
			List<Stbtdttopy> exlist=CM.getDao().listModule("按照统计["+staDateStr+"]的量", sql, Stbtdttopy.class, new Object[]{staDateStr});
			if (exlist!=null && !exlist.isEmpty()) {
			for (Stbtdttopy stbtdttopy : exlist) {
				stbtdttopy.setId(UUIDGenerator.getUUID());//设置主键  
				stbtdttopy.setStatLevel("3"); //统计级别： 1 内外网 2 管理范围内 3 节点之间
				stbtdttopy.setmTime(now);//统计时间 
			}
			//删除staDateStr当月的量
			sql="delete from "+SI_TABLE("turbo_st_bt_dt_top_y")+"  where  to_char(nt,'"+pattern+"')=? and stat_level='3'";
			CM.getDao().delete("删除按照" +"["+staDateStr+"]的发送数据统计", sql, new Object[]{staDateStr});
			
				CM.getDao().batchInsertModule("批量插入按照"+"统计["+staDateStr+"]的量", exlist);
			}
			/**********************按照节点间  入库end **********************************/
			
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
			
	}
}
